package org.ezplatform.office.meeting.task.dao;

import java.util.Date;
import java.util.List;

import org.ezplatform.core.dao.jpa.JpaBaseDao;
import org.ezplatform.office.meeting.task.entity.MeetingTaskInfo;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

@Repository
public interface MeetingTaskInfoDao extends JpaBaseDao<MeetingTaskInfo, String>{

	@Modifying
    @Query(value = "update MeetingTaskInfo set progress = ?1 where id in (?2)")
    int updateProgress(int progress, String... ids );
	
	@Modifying
    @Query(value = "update MeetingTaskInfo set comDetails = ?1 where id = ?2")
    int updateDetails(String comDetails, String id );
	
	@Modifying
    @Query(value = "delete from MeetingTaskInfo where id = ?1 ")
    int deleteTask(String id);
	
	@Modifying
    @Query(value = "delete from MeetingTaskInfo where applyRecordId in (?1) ")
    int deleteByRecordId(String... applyRecordId);
	
	@Query(value = "select id from MeetingTaskInfo where applyRecordId in (?1) ")
    List<String> findTaskInfoIdsByApplyRecordIds(String applyRecordId);
	
    @Query(value = "from MeetingTaskInfo where endTime > ?1 and remindTime != '0' and progress != '100' ")
    List<MeetingTaskInfo> findTaskInfo(Date endTime);
    
    @Query(value = "from MeetingTaskInfo where applyRecordId = ?1 and title = ?2 ")
    MeetingTaskInfo findTaskInfo(String applyRecordId, String title);
}
